Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
CI is failing due to unrelated issues |
|
Hey @A-Manning 👋 Thank you very much for this work. It's been a long time since I wanted to improve the usage of the |
0072559 to
0056d69
Compare
|
Hey @A-Manning 👋 I rebased your PR on top of main, and as we can see, the unrelated errors disappear. However, we can also see that the code you added is not compiling. Could you please fix it? Have a nice day 🌵 |
79d46c6 to
2bc86bf
Compare
|
@Kerollmops Thanks, I've fixed the doctests |
2bc86bf to
df08f41
Compare
df08f41 to
8207a16
Compare
|
|
||
| impl<'txn, KC, DC, IM> RwIter<'txn, KC, DC, IM> { | ||
| /// Advance the iterator to the next item. | ||
| pub fn next<'a>(&'a mut self) -> Option<Result<RwIterItem<'a, 'txn, KC, DC, IM>>> |
There was a problem hiding this comment.
hello, isn't this a breaking change?
Rust prefers inherent methods to trait methods, so adding this inherent methods shadows Iterator::next, meaning that any existing call to an RwIter Iterator's next method will use this different, more constrained signature.
It might also be clearer for it to have a different name as it does something different than a regular iterator. Maybe lend_next?
Pull Request
What does this PR do?
This PR introduces a safer API for
RwIter, as a lending iterator.It is not possible to keep a reference to the key or data at the current cursor after deleting or inserting at the current cursor. If one chooses not to insert or delete at the current cursor, it is possible to keep a reference to the key or data until the end of the current transaction.
It is only possible to insert at the current cursor with the exact key for the current cursor, which is always owned when inserting. It is not possible to insert at the current cursor after deleting at the current cursor, although it is possible to insert multiple times at the current cursor. It is only possible to insert or delete at the current cursor once the cursor has been initialized via a call to
RwIter::nextorRwIter::last.PR checklist
Please check if your PR fulfills the following requirements: